<?php

namespace yiike\toker\models;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use yiike\toker\models\TokerCombo;

/**
* TokerComboSearch represents the model behind the search form about `yiike\toker\models\TokerCombo`.
*/
class TokerComboSearch extends TokerCombo
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id', 'weid', 'credit', 'day_limit', 'status'], 'integer'],
            [['title', 'sub_title', 'logo', 'content'], 'safe'],
            [['price', 'task_money', 'task_tyc', 'parent1_commision', 'parent2_commision', 'community_commision', 'company_commision'], 'number'],
];
}

/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}

/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = TokerCombo::find();

$dataProvider = new ActiveDataProvider([
'query' => $query,
]);

$this->load($params);

if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}

$query->andFilterWhere([
            'id' => $this->id,
            'weid' => $this->weid,
            'price' => $this->price,
            'credit' => $this->credit,
            'task_money' => $this->task_money,
            'task_tyc' => $this->task_tyc,
            'day_limit' => $this->day_limit,
            'parent1_commision' => $this->parent1_commision,
            'parent2_commision' => $this->parent2_commision,
            'community_commision' => $this->community_commision,
            'company_commision' => $this->company_commision,
            'status' => $this->status,
        ]);

        $query->andFilterWhere(['like', 'title', $this->title])
            ->andFilterWhere(['like', 'sub_title', $this->sub_title])
            ->andFilterWhere(['like', 'logo', $this->logo])
            ->andFilterWhere(['like', 'content', $this->content]);

return $dataProvider;
}
}